﻿using HomagGroup.Base.UI;
using HomagGroup.BaseUI.Router;
using System;
using System.Reflection;
using System.Threading.Tasks;
using System.Windows;
using hgw = HomagGroup.Base.UI.Windows;

namespace HomagChina.CCT.BaseUI
{
    public partial class App : Application
    {
        private SingleInstanceApplication _Mutex;
        private hgw.SplashScreenWindow _SplashScreenWindow;

        public App()
        {
            _Mutex = new SingleInstanceApplication();
            if (_Mutex.IsAnyOtherInstanceRunning())
            {
                _Mutex.ActivateOtherInstance();
                Environment.Exit(-1);
            }
        }

        protected override async void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            _SplashScreenWindow = new hgw.SplashScreenWindow();
            _SplashScreenWindow.OnStartup("HOMAG CellControl Transport", Assembly.GetExecutingAssembly().GetName().Version.ToString(),
                "HOMAG-CCT", "HOMAG-CCT", "© 2023 - 2024 HOMAG Group CellControl Transport");
            await Task.Delay(1000);
            _SplashScreenWindow.Close();
            UIAdjustments.CurrentThreadLanguageManager.CultureChanged += NavigateServices.Instance.LanguageManagerCultureChanged;
            var app= new RouterModel();
            app.start();
        }
    }
}